{% extends 'admin_base.html' %}
{% load i18n %}

{% block actions %}
{% if slack_active %}
<a hx-get="{% url 'people:sync-slack' %}" hx-swap="outerHTML" hx-target="body" class="btn btn-primary d-none d-sm-inline-block" hx-indicator="#spinner-slack">
  <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-slack" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
     <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
     <path d="M12 12v-6a2 2 0 0 1 4 0v6m0 -2a2 2 0 1 1 2 2h-6"></path>
     <path d="M12 12h6a2 2 0 0 1 0 4h-6m2 0a2 2 0 1 1 -2 2v-6"></path>
     <path d="M12 12v6a2 2 0 0 1 -4 0v-6m0 2a2 2 0 1 1 -2 -2h6"></path>
     <path d="M12 12h-6a2 2 0 0 1 0 -4h6m-2 0a2 2 0 1 1 2 -2v6"></path>
  </svg>
  {% translate "Sync with Slack" %}
  <span class="requesting alsodisplay spinner-border spinner-border-sm me-2" id="spinner-slack" role="status"></span>
</a>
{% endif %}
{% if request.user.is_admin %}
  {% for import_user_option in import_users_options %}
    <a href="{% url "people:import" import_user_option.id %}" class="btn btn-primary d-none d-sm-inline-block">
      {% blocktranslate with service=import_user_option.name %}Import users with {{ service }}{% endblocktranslate %}
    </a>
  {% endfor %}
{% endif %}
{% endblock %}

{% block content %}
<div class="col-12">
  <div class="card">
    <div class="table-responsive">
      <table class="table card-table table-vcenter text-nowrap">
        <thead>
          <tr>
            <th>{% translate "Name" %}</th>
            <th>{% translate "Position" %}</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for colleague in object_list %}
          <tr>
            <td>
              {% include "_table_user.html" with user=colleague %}
            </td>
            <td>
              {{ colleague.position }}
            </td>
            <td class="text-end">
              {% if slack_active %}
                {% include "_toggle_colleague_access.html" with url_name="people:connect-to-slack" slack=True exists=colleague.has_slack_account %}
              {% endif %}
              {% if colleague.role == UserRole.OTHER %}
                {% include "_toggle_colleague_access.html" with url_name="people:toggle-portal-access" exists=colleague.is_active %}
              {% endif %}
              <a href="{% url 'people:colleague' colleague.id %}" class="btn btn-white">
                {% translate "View" %}
              </a>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
    {% include "_paginator.html" %}
  </div>
</div>
{% endblock %}
